package com.fxu.framework.core.enums;

import com.fxu.framework.biz.base.Limits;
import lombok.AllArgsConstructor;

/***
 * 流程status字段字符串枚举
 * 请使用AuditStatus
 * @author fangxu
 * @version 1.0.0
 ***/
@Deprecated
@AllArgsConstructor
public enum ProcessStatus implements BaseEnum<String, String> {
    //Pending:待处理,DELETE:删除,Cancel:已取消,Doing:进行中,Finish:已完成
    DELETE("DELETE", "删除"),
    Pending("Pending", "待处理"),
    Cancel("Cancel", "已取消"),
    Doing("Doing", "进行中"),
    Finish("Finish", "已完成")
    ;

    final String code;
    final String desc;

    @Override
    public String code() {
        return code;
    }

    @Override
    public String desc() {
        return desc;
    }

    public static String desc(String code) {
        ProcessStatus ret = find(code);
        return ret == null ? null : ret.desc;
    }

    public static ProcessStatus find(String code) {
        return code == null ? null : BaseEnum.findOne(values(), v -> v.code.equals(code));
    }

    public static boolean is(String limits) {
        ProcessStatus[] enums = ProcessStatus.values();
        String[] array = new Limits(limits).getArray();
        for (ProcessStatus e : enums) {
            if (BaseEnum.findOne(array, v -> v.equals(e.code + Limits.SPLIT_CHILD + e.desc)) == null) {
                return false;
            }
        }
        for (String s : array) {
            if (BaseEnum.findOne(enums, v -> s.equals(v.code + Limits.SPLIT_CHILD + v.desc)) == null) {
                return false;
            }
        }
        return true;
    }
}